*** This code produces robustness tests (Tables A.3-A.14 & Figure A.2 in the online appendix		***
*** For Tuttnauer & Wegmann in APSR 																***
*** "Voting for Votes: Opposition Parties’ Legislative Activity and Electoral Outcomes"				***


*** Install needed packages 
ssc install blindschemes, replace /* to use plotplain scheme for graphs */
ssc install outreg2, replace /* to export regression tables to RTF format */

use TW_partyterm_data.dta, clear 

** Table A.3: Additional control variables
fracreg logit next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size minority_cab oversized ///
	enps federal proportional openness cee demo_age ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a3, word dec(3) ctitle(No interaction) replace

fracreg logit next_voteshare c.conflict_rate##c.ppop vote_share ideo_gap gdpgrowth ///
	early_election ///
	enps_cab cabinet_size minority_cab oversized ///
	enps federal proportional openness cee demo_age ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a3, word dec(3) ctitle(Institutions) append

fracreg logit next_voteshare c.conflict_rate##c.vote_share ppop ideo_gap gdpgrowth ///
	early_election ///
	enps_cab cabinet_size minority_cab oversized ///
	enps federal proportional openness cee demo_age ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a3, word dec(3) ctitle(Size) append

fracreg logit next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size minority_cab oversized ///
	enps federal proportional openness cee demo_age ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a3, word dec(3) ctitle(Ideology) append

** Table A.4: OLS regression
reg next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record
outreg2 using table_a4.doc, replace dec(3) ctitle(No interaction)

reg next_voteshare c.conflict_rate##c.ppop vote_share ideo_gap gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record
outreg2 using table_a4.doc, append dec(3) ctitle(Institutions)

reg next_voteshare c.conflict_rate##c.vote_share ideo_gap ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record
outreg2 using table_a4.doc, append dec(3) ctitle(Size)

reg next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record
outreg2 using table_a4.doc, append dec(3) ctitle(Ideology)

** Table A.5: Tobit regression
tobit next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, ll(0) ul(1)
outreg2 using table_a5.doc, replace dec(3) ctitle(No interaction)

tobit next_voteshare c.conflict_rate##c.ppop vote_share ideo_gap gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, ll(0) ul(1)
outreg2 using table_a5.doc, append dec(3) ctitle(Institutions)

tobit next_voteshare c.conflict_rate##c.vote_share ideo_gap ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, ll(0) ul(1)
outreg2 using table_a5.doc, append dec(3) ctitle(Size)

tobit next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, ll(0) ul(1)
outreg2 using table_a5.doc, append dec(3) ctitle(Ideology)

** Table A.6: Using country fixed effects
fracreg logit next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record i.country_id start_date
outreg2 using table_a6, word dec(3) ctitle(No interaction) replace

fracreg logit next_voteshare c.conflict_rate##c.ppop ideo_gap vote_share gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record i.country_id start_date
outreg2 using table_a6, word dec(3) ctitle(Institutions) append

fracreg logit next_voteshare c.conflict_rate##c.vote_share ideo_gap ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record i.country_id start_date
outreg2 using table_a6, word dec(3) ctitle(Size) append

fracreg logit next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record i.country_id start_date
outreg2 using table_a6, word dec(3) ctitle(Ideology) append

** Table A.7: Using cabinet fixed effects
fracreg logit next_voteshare conflict_rate ideo_gap vote_share ppop ///
	 federal proportional ///
	frequency full_record i.cabinet_id 
outreg2 using table_a7, word dec(3) ctitle(No interaction) replace

fracreg logit next_voteshare c.conflict_rate##c.ppop ideo_gap vote_share  ///
	 federal proportional ///
	frequency full_record i.cabinet_id
outreg2 using table_a7, word dec(3) ctitle(Institutions) append

fracreg logit next_voteshare c.conflict_rate##c.vote_share ideo_gap ppop  ///
	 federal proportional ///
	frequency full_record i.cabinet_id
outreg2 using table_a7, word dec(3) ctitle(Size) append

fracreg logit next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop  ///
	 federal proportional ///
	frequency full_record i.cabinet_id
outreg2 using table_a7, word dec(3) ctitle(Ideology) append

** Table A.8: Testing clarity of responsibility effect
fracreg logit next_voteshare c.conflict_rate##c.enps_cab ideo_gap vote_share gdpgrowth ///
	early_election ///
	 cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a8.doc, replace dec(3) ctitle(Cabinet fragmentation)
	
fracreg logit next_voteshare c.conflict_rate##minority_cab ideo_gap vote_share gdpgrowth ///
	early_election ///
	 cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
	outreg2 using table_a8.doc, append dec(3) ctitle(Minority cabinet)

fracreg logit next_voteshare c.conflict_rate##oversized ideo_gap vote_share gdpgrowth ///
	early_election ///
	 cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
	outreg2 using table_a8.doc, append dec(3) ctitle(Oversized cabinet)

** Table A.9: Testing government effect experience
fracreg logit next_voteshare c.conflict_rate##c.govexp ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a9.doc, replace dec(3) ctitle(Continuous)
	
fracreg logit next_voteshare c.conflict_rate##bi_govexp ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a9.doc, append dec(3) ctitle(Binary)

** Table A.10: Testing effect of economic conditions
fracreg logit next_voteshare ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a10.doc, replace dec(3) ctitle(No conflict)

fracreg logit next_voteshare c.conflict_rate##c.gdpgrowth ideo_gap vote_share ppop  ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record, vce(cluster cabinet_id)
outreg2 using table_a10.doc, append dec(3) ctitle(Interaction)

* Figure A.2: interaction with GDP growth
margins, dydx(conflict_rate) at(gdpgrowth = (-6 (2) 8))
marginsplot, scheme(plotplain)  ///
	ytitle("Effect of conflict on vote share") ///
	xtitle("GDP Growth") ///
	title("") yline(0) ///
	addplot(hist gdpgrowth, yaxis(2) yscale(axis(2) alt) ///
	fintensity(inten30) color(%30) legend(off) ytitle("Density of conflict rate", axis(2) size(small)) xlabel(-6 (2) 8))
graph export figure_a2.tif, replace

fracreg logit next_voteshare c.conflict_rate##c.unemployment ideo_gap vote_share ppop  ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record  if left_right<5, vce(cluster cabinet_id)
outreg2 using table_a10.doc, append dec(3) ctitle(Left and unemployment)

fracreg logit next_voteshare c.conflict_rate##c.inflation ideo_gap vote_share ppop  ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record  if left_right>5, vce(cluster cabinet_id)
outreg2 using table_a10.doc, append dec(3) ctitle(Right and inflation)

** Tables A.11-A.14: Dropping specific countries
forvalues i = 1/10 {
fracreg logit next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size  ///
	enps federal proportional ///
	frequency full_record if country_id!=`i', vce(cluster cabinet_id)
outreg2 using table_a11.doc, append ctitle(without `i')

fracreg logit next_voteshare c.conflict_rate##c.ppop vote_share ideo_gap gdpgrowth ///
	early_election ///
	enps_cab cabinet_size ///
	enps federal proportional ///
	frequency full_record if country_id!=`i', vce(cluster cabinet_id)
outreg2 using table_a12.doc, append ctitle(without `i')

fracreg logit next_voteshare c.conflict_rate##c.vote_share ideo_gap ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size  ///
	enps federal proportional  ///
	frequency full_record if country_id!=`i', vce(cluster cabinet_id)
outreg2 using table_a13.doc, append ctitle(without `i')

fracreg logit next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size  ///
	enps federal proportional  ///
	frequency full_record if country_id!=`i', vce(cluster cabinet_id)
outreg2 using table_a14.doc, append ctitle(without `i')

}

fracreg logit next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size  ///
	enps federal proportional ///
	frequency full_record if country!="ESP" & country!="LTU", vce(cluster cabinet_id)
outreg2 using table_a11.doc, append ctitle(without ESP & LIT)

fracreg logit next_voteshare c.conflict_rate##c.ppop vote_share ideo_gap gdpgrowth ///
	early_election ///
	enps_cab cabinet_size ///
	enps federal proportional ///
	frequency full_record if country!="ESP" & country!="LTU", vce(cluster cabinet_id)
outreg2 using table_a12.doc, append ctitle(without ESP & LIT)

fracreg logit next_voteshare c.conflict_rate##c.vote_share ideo_gap ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size  ///
	enps federal proportional  ///
	frequency full_record if country!="ESP" & country!="LTU", vce(cluster cabinet_id)
outreg2 using table_a13.doc, append ctitle(without ESP & LIT)

fracreg logit next_voteshare c.conflict_rate##c.ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size  ///
	enps federal proportional  ///
	frequency full_record if country!="ESP" & country!="LTU", vce(cluster cabinet_id)
outreg2 using table_a14.doc, append ctitle(without ESP & LIT)



*** Additional analyses mentioned in the text

** Multicollinearity (mentioned in footnote 9)
reg  next_voteshare conflict_rate ideo_gap vote_share ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record ///
	, cluster(cabinet_id)
vif

*** Using seat share instead of vote share (mentioned in footnote 12)
fracreg logit next_voteshare c.conflict_rate##c.party_size ideo_gap ppop gdpgrowth ///
	early_election ///
	enps_cab cabinet_size   ///
	enps federal proportional ///
	frequency full_record ///
	, vce(cluster cabinet_id)
	
